home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-16 | 2.8 KB | 130 lines | [TEXT/CWIE] |
- //====
- // ISpEventPane.cp
- //=====
-
- #include "ISpEventPane.h"
- #include "ISpTestGlobals.h"
- #include <TextUtils.h>
- #include "ISpPPTestTools.h"
-
- ISpEventPane::ISpEventPane(LStream *inStream):LOffscreenView(inStream)
- {
- mDataValid = false;
- StartIdling();
- }
-
- ISpEventPane::~ISpEventPane()
- {
- }
-
- ISpEventPane *ISpEventPane::CreateISpEventPaneStream(LStream *inStream)
- {
- return (new ISpEventPane(inStream));
- }
-
-
- void ISpEventPane::SpendTime(const EventRecord &inMacEvent)
- {
-
- if (gElementList == nil) { return; }
-
- ISpElementEvent theEvent;
-
- OSStatus theErr;
- Boolean wasEvent;
-
- theErr = ISpElementList_GetNextEvent( gElementList,
- sizeof(ISpElementEvent),
- &theEvent,
- &wasEvent);
-
- if (wasEvent)
- {
- mDataValid = true;
-
- mPrintRecord.theError = theErr;
- mPrintRecord.when = theEvent.when;
- mPrintRecord.data = theEvent.data;
- mPrintRecord.theElement = theEvent.element;
- mPrintRecord.refCon = theEvent.refCon;
- mPrintRecord.percent = theEvent.data;
- float max = 0xffffffff;
- mPrintRecord.percent /= max;
-
- ISpElementInfo info;
- ISpElement_GetInfo(theEvent.element, &info);
- mPrintRecord.label = info.theLabel;
- mPrintRecord.kind = info.theKind;
- BlockMoveData(info.theString, mPrintRecord.theString, 64);
- Refresh();
- UpdatePort();
- }
- }
-
-
-
- void ISpEventPane::DrawSelf()
- {
- if (!mDataValid) { return; }
-
- Rect r;
- Str255 theString;
-
- CalcLocalFrameRect(r);
- r.left += 10;
- EraseRect(&r);
-
- MoveTo(r.left, r.top + 15);
- DrawString("\pError Code: ");
- NumToString(mPrintRecord.theError, theString);
- DrawString(theString);
-
- MoveTo(r.left, r.top + 30);
- DrawString("\pTime: ");
- UnsignedWideToHexString(mPrintRecord.when, theString);
- DrawString(theString);
-
- MoveTo(r.left, r.top + 45);
- DrawString("\pData: ");
- UInt32ToHexString(mPrintRecord.data, theString);
- DrawString(theString);
-
- {
- const rectWidth = 100;
- Rect maxRect = {2,0,11,rectWidth};
- Rect progRect = maxRect;
-
- progRect.right = rectWidth * mPrintRecord.percent;
-
- OffsetRect(&maxRect, r.left, r.top + 47);
- OffsetRect(&progRect, r.left, r.top + 47);
-
- ::FrameRect(&maxRect);
- ::PaintRect(&progRect);
- }
-
- MoveTo(r.left, r.top + 75);
- DrawString("\pElement Num: ");
- UInt32ToHexString((unsigned long) mPrintRecord.theElement, theString);
- DrawString(theString);
-
- MoveTo(r.left, r.top + 90);
- DrawString("\prefCon: ");
- UInt32ToHexString(mPrintRecord.refCon, theString);
- DrawString(theString);
-
- MoveTo(r.left, r.top + 105);
- DrawString("\pElement Label: ");
- UInt32ToFourByte(mPrintRecord.label, theString);
- DrawString(theString);
-
- MoveTo(r.left, r.top + 120);
- DrawString("\pElement Kind: ");
- UInt32ToFourByte(mPrintRecord.kind, theString);
- DrawString(theString);
-
- MoveTo(r.left, r.top + 135);
- DrawString("\pElement Name: ");
- DrawString(mPrintRecord.theString);
-
- }